<?php

namespace app\models\db;

use Yii;

/**
 * This is the model class for table "t_goods_category_goods".
 *
 * @property string $id
 * @property string $goods_category_id
 * @property string $goods_id
 *
 * @property TGoods $goods
 * @property TGoodsCategory $goodsCategory
 */
class GoodsCategoryGoods extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 't_goods_category_goods';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id'], 'required'],
            [['id', 'goods_category_id', 'goods_id'], 'string', 'max' => 36],
            [['goods_id'], 'exist', 'skipOnError' => true, 'targetClass' => TGoods::className(), 'targetAttribute' => ['goods_id' => 'id']],
            [['goods_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => TGoodsCategory::className(), 'targetAttribute' => ['goods_category_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'goods_category_id' => 'Goods Category ID',
            'goods_id' => 'Goods ID',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getGoods()
    {
        return $this->hasOne(TGoods::className(), ['id' => 'goods_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getGoodsCategory()
    {
        return $this->hasOne(TGoodsCategory::className(), ['id' => 'goods_category_id']);
    }
}
